<template>
	<view class="container">
		<TopBtn :title="'会诊设置'"></TopBtn>
		<view class="info">
			<view class="currency_card flex-sp-center mb_30">
				会诊状态
				<switch :checked="Status" @change='switch1Change' style="transform:scale(0.6)" />
			</view>
			<view class="currency_card pb_37 mb_30">
				<view class="">
					<view class="mb_30">
						<text class="red">*</text> 会诊费用
					</view>
					<view class="">
						<uni-easyinput v-model="data.consultationFee" type="number" placeholder="请设置会诊费用"></uni-easyinput>
					</view>
				</view>
			</view>
			<view class="warning currency_card  pb_37">
				<view class="title flex-center">
					<image src="@/static/CommonTools/warning.png" mode=""></image> 注意事项
				</view>
				<view class="text">
					1、此费用为会诊一次的金额。
				</view>
			</view>
		</view>
		<view class="CommonToolsbtn flex-center-center" @click="createDoctorAppoint()">
			保存
		</view>

	</view>
</template>

<script>
	import {
		commonToolsGet,
		createDoctorAppoint
	} from '@/api/commonTools'
	export default {
		data() {
			return {
				data: {

				},
				Status: false
			}
		},
		onLoad() {
			this.commonToolsGet()
		},
		methods: {
			switch1Change: function(e) {
				if (e.detail.value) {
					this.data.consultationStatus = 1
				} else {
					this.data.consultationStatus = 0
				}
			},
			commonToolsGet() {
				commonToolsGet().then(res => {
					this.data = res.data
					if (this.data && this.data.consultationStatus == 1) {
						this.Status = true
					} else {
						this.Status = false
					}
				})
			},
			createDoctorAppoint() {
				if (!this.data.consultationFee&&this.data.consultationStatus == 1) {
					uni.showToast({
						title: '请填写会诊费用',
						icon: 'none',
						duration: 2000,
					})
					return
				}
				createDoctorAppoint(this.data).then(res => {
					this.data = res.data
					uni.showToast({
						title: '操作成功',
						duration: 2000,
						icon: 'none',
						mask: true
					})
					this.commonToolsGet()
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	/deep/.is-input-border {
		border: none;
		background-color: #FAFAFA !important;
	}

	.info {
		padding: 30rpx;
	}

	.currency_card {
		font-size: 28rpx
	}

	.warning {
		image {
			width: 30rpx;
			height: 30rpx;
			margin-right: 15rpx;
		}

		font-weight: 500;
		font-size: 28rpx;
		color: #333333;

		.text {
			color: #999;
		}
	}
</style>